﻿Imports DTO
Imports System.Data.SqlClient
Public Class CGhiNhanMatSachDAO
    Public Function ThemGhiNhan(ByVal ghinhan As CGhiNhanMatSachDTO) As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As SqlCommand = New SqlCommand("uspThemGhiNhan", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As SqlParameter = New SqlParameter("@madocgia", ghinhan.MaDocGia)
            cm.Parameters.Add(para)
            para = New SqlParameter("@manhanvien", ghinhan.MaNhanVien)
            cm.Parameters.Add(para)
            para = New SqlParameter("@masach", ghinhan.MaSach)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ngayghinhan", ghinhan.NgayGhiNhan)
            cm.Parameters.Add(para)
            para = New SqlParameter("@tienphat", ghinhan.TienPhat)
            cm.Parameters.Add(para)
            para = New SqlParameter("@machitietphieu", ghinhan.MaChiTietPhieu)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ma", 0)
            para.Direction = ParameterDirection.Output
            cm.Parameters.Add(para)
            Dim n As Integer = cm.ExecuteNonQuery()
            cn.Close()
            Return n
        End Using
    End Function
End Class
